<?php

	$search = mysql_escape_string($_POST['txt_search']);
	
	$sql = "SELECT a.page_name, b.content, a.link_name AS link
			FROM ".$base_obj->PAGE." a
			INNER JOIN ".$base_obj->SECTION." b ON ( a.id = b.page_name )
			WHERE (
			b.content LIKE '%".$search."%'
			OR a.page_name LIKE '%".$search."%'
			OR b.section_name LIKE '%".$search."%'
			) AND a.active_status = '1'	AND b.active_status = '1'
			UNION
			SELECT university_name, description, CONCAT('universities&view=univ&srch_id=',ID) AS link 
			FROM `university` WHERE (university_name LIKE '%".$search."%' OR description LIKE '%".$search."%') 
			AND active_status = '1'
			UNION
			SELECT course_name, `desc`, CONCAT('universities&view=course&srch_id=',id) AS link 
			FROM `course` WHERE (course_name LIKE '%".$search."%' OR `desc` LIKE '%".$search."%') AND active_status = '1'
			UNION
			SELECT scholarship_name, `details_description`, 
			CONCAT('universities&view=scholar&srch_id=',scholarship_name) AS link 
			FROM `scholarships` WHERE (scholarship_name LIKE '%".$search."%' OR `details_description` LIKE '%".$search."%') 
			AND active_status = '1'
			UNION
			SELECT `category` , `desc` , CONCAT( 'classifieds&view=cat&cat_id=', id )
			FROM `classifieds_category`	WHERE (category LIKE '%".$search."%' OR 
			`desc` LIKE '%".$search."%') AND active_status = '1'
			UNION
			SELECT `sub_cat_name` , `desc` , CONCAT( 'classifieds&view=cat&cat_id=', id )
			FROM `classifieds_subcategory`	WHERE (sub_cat_name LIKE '%".$search."%' OR 
			`desc` LIKE '%".$search."%') AND active_status = '1'
			UNION
			SELECT item, description, CONCAT('classifieds&view=ad&cat_id=',id) AS link	
			FROM classifieds_ads 
			WHERE (item LIKE '%".$search."%' OR description LIKE '%".$search."%') AND Status = '1'
			UNION
			SELECT job_nature, job_desc, 'jobs' AS link
			FROM `job_post`	WHERE (job_nature LIKE '%".$search."%' OR job_desc LIKE '%".$search."%') AND active_status = '1'
			UNION
			SELECT make, specifications, CONCAT('technology&mode=view&make_id=',make) AS link
			FROM `gadget_technology` WHERE (make LIKE '%".$search."%' OR specifications LIKE '%".$search."%') 
			AND active_status = '1'
			UNION
			SELECT gadget_name, gadget_desc, CONCAT('technology&mode=view&srch_id=',gadget_id) AS link
			FROM gadget WHERE (gadget_name LIKE '%".$search."%'	OR gadget_desc LIKE '%".$search."%') AND active_status = '1'
			UNION
			SELECT concat( `book_name` , ' by ', `author` ) title, `book_desc` , 'books' AS link
			FROM `books` 
			WHERE (book_name LIKE '%".$search."%' OR book_desc LIKE '%".$search."%' OR 
			author LIKE '%".$search."%') AND active_status = '1'";

	$res = $base_obj->exec_query($sql);
	$data = $base_obj->fetch_row_all($res);
	
	if(count($data) > 0) {
		for($i=0;$i<count($data);$i++) {
			$db_cont .= 
			'<div class="borders" style="padding:3px 3px 3px 3px; margin:5px 5px 5px 5px;"><h2 style="padding-left:0px; font-size:18px;" class="classifiedstitle" ><a href = "index.php?page='.stripslashes($data[$i]['link']).'" title = "'.stripslashes($data[$i]['page_name']).'" style="color:#098BBB">'.$data[$i]['page_name'].'</a></h2>
			<span class="font12">'.substr(stripslashes(strip_tags($data[$i]['content'])),0,200).'</span>
			</div>';
		}
	}
	else {
		$db_cont = "<div style=\"margin-top:100px;margin-bottom:100px;\"> '".$search. "' not found </div>";
	}
	$content .= 
	'<div style="background-color: rgb(255, 255, 255); float: left; width: 970px; color:#000;">
	  '.$db_cont.'
	</div>';
		
		
?>		

	<div class="contentwarp" style="width:970px;">
      <div class="contentwarpMiddle">
        <div class="clearfix" id="the-content">
          <?php echo $content; ?>
        </div>
      </div>
      <!-- End contentwarpMiddle -->
      <div class="contentwarpRight" style="background-color:#FFF;">
      <?php //include("includes/right_content.php");?>
      </div>
      <!-- End contentwarp -->
    </div>